<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024-9-22
  Time: 16:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%--ctxPath--%>
<c:set var="ctxPath" value="${pageContext.request.contextPath}" />
<%--项目路径 --%>
<c:set var="path" value="${ctxPath}" />
<%--静态文件目录 --%>
<c:set var="staticPath" value="${ctxPath}" />
<html>
<head>
    <link href="${staticPath }/views/css/font-awesome.min.css" rel="stylesheet"/>
    <title>博客文章管理</title>
    <style>
        /*.search-wrap {*/
        /*    padding: 15px 0;*/
        /*    border-bottom: 1px solid #e5e5e5;*/
        /*}*/
        .label {
            height: 30px;
            line-height: 30px;
            padding: 2px 4px;
        }
        .common-text {
            height: 30px;
            line-height: 30px;
            padding: 2px 4px;
            border: 1px solid #ccc;
            background: #fff;
            border-radius: 5px;
        }
        .search-tab tr {
            line-height: 35px;
        }

        .search-tab th {
            text-align: right;
            padding-right: 10px;
            font-weight: normal;
        }

        .search-tab td {
            padding: 0 5px;
        }
        .result-tab {
            border-collapse: collapse;
            border: 1px solid #ddd;
            width: 100%;
        }

        .result-tab th {
            font-weight: normal;
            font-size: 15px;
            text-align: center;
            /*background: url(../images/tab-thbg.png) #f9f9f9 0 bottom repeat-x;*/
        }

        .result-tab th,.result-tab td {
            padding: 5px;
            border-bottom: 1px solid #ddd;
            border-right: 1px solid #e1e1e1;
        }

        .result-tab tr {
            line-height: 35px;
        }

        .result-tab th.tc,.result-tab td.tc {
            text-align: center;
        }

        .result-tab tr:nth-child(odd) {
            background: #f9f9f9;
        }

        .result-tab tr:hover {
            background: #f1f1f1;
        }

        .result-tab tr.even-tr {
            background: #e9fff2;
        }
        a:link {text-decoration: none;color:dodgerblue;}

        a:visited {color:green；text-decoration:none;}

        a:hover  {color:blue;text-decoration:underline;}

        a:active {color:orange;text-decoration:blink;}
    </style>
</head>
<body>
<div style="text-align: center;">
    <h2>博客文章管理</h2>
</div>
<div class="search-wrap">
    <div class="search-content">
        <form action="#" method="post">
            <table class="search-tab">
                <tr>

                    <th class="label" >标题:</th>
                    <td><input class="common-text" placeholder="请输入标题..."
                               name="keywords" value="" type="text"></td>

                    <td>
                        <input class="btn btn-primary btn2" name="sub" style="height: 30px;" value="查询"
                               type="submit"></td>

                </tr>
            </table>
        </form>
    </div>
</div>
<div>
    <h3>
        <a href="ArticleServlet?method=new"><i class="fa fa-plus"></i> 新增博客文章</a>
    </h3>
</div>
<div class="result-content">
    <table class="result-tab">
        <tbody>
        <tr>
            <th style="width: 20%">标题</th>
            <th style="width: 30%">文章内容</th>
            <th style="width: 10%">博客分类</th>
            <th style="width: 10%">作者</th>
            <th style="width: 10%">发布时间</th>
            <th style="width: 20%">操作</th>
        </tr>
        <c:forEach items="${articleList}" var="article">
            <tr>
                <td>${article.title}</td>
                <td>${article.content}</td>
<%--                <td>${article.categoryId}</td>--%>
<%--                <td>${article.userId}</td>--%>
                <c:forEach items="${categoryList}" var="category">
                    <c:if test="${article.categoryId eq category.id}">
                        <td>${category.name}</td>
                    </c:if>
                </c:forEach>
                <c:forEach items="${userList}" var="user">
                    <c:if test="${article.userId eq user.id}">
                        <td>${user.name}</td>
                    </c:if>
                </c:forEach>
                <td>${article.createdTime}</td>
                <td style="text-decoration:none;text-align:center">
                    <a href="ArticleServlet?method=edit&id=${article.id}">编辑</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="ArticleServlet?method=delete&id=${article.id}">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>